package com.ruoyi.community.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.community.domain.ServiceQuestionType;
import com.ruoyi.community.mapper.ServiceQuestionTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.community.mapper.ServiceQuestionsMapper;
import com.ruoyi.community.domain.ServiceQuestions;
import com.ruoyi.community.service.IServiceQuestionsService;

/**
 * 社区Service业务层处理
 * 
 * @author 袁现程
 * @date 2021-08-01
 */
@Service
public class ServiceQuestionsServiceImpl implements IServiceQuestionsService 
{
    @Autowired
    private ServiceQuestionsMapper serviceQuestionsMapper;
    @Autowired
    private ServiceQuestionTypeMapper serviceQuestionTypeMapper;

    /**
     * 查询问题
     */
    @Override
    public ServiceQuestions selectServiceQuestionsById(Long id)
    {
        return serviceQuestionsMapper.selectServiceQuestionsById(id);
    }

    /**
     * 查询问题列表
     */
    @Override
    public List<ServiceQuestions> selectServiceQuestionsList(ServiceQuestions serviceQuestions)
    {
        serviceQuestions.setCommunityId(Long.valueOf(SecurityUtils.getCommunityId()));
        return serviceQuestionsMapper.selectServiceQuestionsList(serviceQuestions);
    }

    /**
     * 新增问题
     */
    @Override
    public int insertServiceQuestions(ServiceQuestions serviceQuestions)
    {
        serviceQuestions.setCommunityId(Long.valueOf(SecurityUtils.getCommunityId()));
        serviceQuestions.setApplyId(0l);
        serviceQuestions.setClickNum(String.valueOf(1));
        Date date = DateUtils.getNowDate();
        serviceQuestions.setCreateTime(date);
        serviceQuestions.setModifyTime(date);
        serviceQuestions.setLogicDelete(false);
        return serviceQuestionsMapper.insertServiceQuestions(serviceQuestions);
    }

    /**
     * 修改问题
     */
    @Override
    public int updateServiceQuestions(ServiceQuestions serviceQuestions)
    {
        return serviceQuestionsMapper.updateServiceQuestions(serviceQuestions);
    }

    /**
     * 批量删除问题
     */
    @Override
    public int deleteServiceQuestionsByIds(Long[] ids)
    {
        return serviceQuestionsMapper.deleteServiceQuestionsByIds(ids);
    }

    /**
     * 删除问题
     */
    @Override
    public int deleteServiceQuestionsById(Long id)
    {
        return serviceQuestionsMapper.deleteServiceQuestionsById(id);
    }

    /**
     * 获取问题类型列表
     */
    @Override
    public List<ServiceQuestionType> getQuestionType() {
        return serviceQuestionTypeMapper.selectQuestionType();
    }

    /**
     * 新增问题类型
     */
    @Override
    public int insertQuestionType(ServiceQuestionType serviceQuestionType) {
        Date date = DateUtils.getNowDate();
        serviceQuestionType.setCreateTime(date);
        serviceQuestionType.setModifyTime(date);
        return serviceQuestionTypeMapper.insert(serviceQuestionType);
    }

    /**
     * 获取申请列表
     */
    @Override
    public List<ServiceQuestions> selectApplyQuestionsList(ServiceQuestions serviceQuestions) {
        serviceQuestions.setCommunityId(Long.valueOf(SecurityUtils.getCommunityId()));
        return serviceQuestionsMapper.selectApplyQuestionsList(serviceQuestions);
    }
}
